package com.example.network.service;

import com.example.network.controller.dto.ShareDTO;
import com.example.network.controller.request.FileRequest;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * @author LR
 */
public interface FileService {

    /**
     * 搜索文件
     *
     * @param filename
     * @param userID
     * @return
     */
    List<FileRequest> selectByFileName(String filename, String userID);

    /**
     * 上传文件
     *
     * @param file
     * @param userID
     * @return
     */
    String uploadFile(MultipartFile chunk,String fileName,int chunkNumber, int totalChunks,String userID,String chunkIndex);

    /**
     * 删除文件
     *
     * @param filename
     * @param userID
     * @return
     */
    Boolean deleteByFileName(String filename, String userID);

    /**
     * 下载文件
     */
    ResponseEntity<FileSystemResource> downloadFile(String filename, String userID) throws IOException;

    /**
     * 查看用户文件
     * @return
     */
    List<FileRequest> selectByAll(String userID);

    /**
     * 创建分享链接
     *
     * @param filePath
     * @return
     */
    ShareDTO shareFile(String filename,String userID);

    ShareDTO findShareID(String shareID,String filePass);


    ResponseEntity<FileSystemResource> downloadFileByShareID(String filePath);
}
